package DMSXL._2023Before.ListNode_;

/*public class getIntersectionNode_ {
    public static void main(String[] args) {

    }
}

class Solution {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if(headA == null || headB == null){
            return headA == null ? headA : headB;
        }
        if(headA == headB){
            return headA;
        }
        ListNode dummyheadA = new ListNode();
        ListNode dummyheadB = new ListNode();
        dummyheadA.next = headA;
        dummyheadB.next = headB;

        ListNode samenode = null;
        while (dummyheadA.next != null){
            dummyheadB.next = headB;
            while(dummyheadB.next != null){
                if(dummyheadA.next == dummyheadB.next){
                    samenode = dummyheadA.next;
                    return  samenode;
                }

                dummyheadB.next = dummyheadB.next.next;
            }
            dummyheadA.next = dummyheadA.next.next;
        }
        return null;
    }
}*/